package com.aixingfu.sports.MVP.presenter;

import android.util.Log;

import com.aixingfu.sports.Https.NetHome;
import com.aixingfu.sports.Https.NetListener;
import com.aixingfu.sports.MVP.contract.CardTypeContract;
import com.aixingfu.sports.MVP.contract.UserUploadContract;
import com.aixingfu.sports.Model.CardTypeModel;
import com.aixingfu.sports.Model.UserUploadModel;
import com.orie.librarybase.BaseApplication;
import com.orie.librarybase.utils.UserUtils;

import java.util.HashMap;

/**
 * Author : 吕冬冬
 * Time : 2019.05.08 0011
 * Description : 单张图片上传
 */
public class CardTypePresenter implements CardTypeContract.MyPresenter {

    CardTypeContract.MyView mView;
    @Override
    public void attachView(CardTypeContract.MyView view) {
        mView=view;
    }

    @Override
    public void detachView() {
        this.mView = null;
    }

    @Override
    public boolean isViewAttached() {
        return mView != null;
    }

    public void getCardType(HashMap<String,String> map){
        mView.showLoading();
        String token = UserUtils.getToken(BaseApplication.getContext());
        NetHome.loadData(NetHome.getApi(mView.getMyContext()).getCardType(token,map), new NetListener<CardTypeModel>() {
            @Override
            public void onSuccess(CardTypeModel data) {
                mView.setCardType(data);
            }

            @Override
            public void onFailed(int errCode, String errMsg) {
                Log.i("打印数据", "onFailed: "+errCode+"  "+errMsg);
            }
            @Override
            public void onComplete() {
                mView.hideLoading();
            }
        });
    }
}
